<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.material.mapper.MaterialMapper">
    <select id="getList" resultType="com.hzb.erp.api.pc.material.pojo.MaterialVO">
        select t1.*
        ,t2.name school_name
        ,t3.name editor_name
        from material t1
        left join org t2 on t2.id = t1.school_id
        left join staff t3 on t3.id = t1.editor
        <where>
            t1.deleted = 0
            <if test="param.name != null and param.name != ''">
                AND t1.name like concat('%', #{param.name}, '%')
            </if>
            <if test="param.state != null">
                AND t1.state = #{param.state}
            </if>
        </where>
        order by t1.id desc
    </select>
    <select id="getInfo" resultType="com.hzb.erp.api.pc.material.pojo.MaterialVO">
        select t1.*,
           t2.name school_name,
        from material t1
        left join org t2 on t2.id = t1.school_id
        where t1.id = #{id}
    </select>
</mapper>
